/*
 * SetPlaceNameCommand.java
 *
 * Created on 11 maj 2007, 23:49
 */

package edu.uj.petri.commands;

import edu.uj.petri.model.Place;
import java.util.ResourceBundle;

/**
 *
 * @author Piotrek
 */
public class SetPlaceNameCommand extends Command {
    
    private Place place;
    
    private String newName;
    
    private String oldName;
    
    /** Creates a new instance of SetPlaceNameCommand */
    public SetPlaceNameCommand(Place place, String name) {
        this.place = place;
        this.newName = name;
        oldName = null;
    }

    public String toString() {
        return ResourceBundle.getBundle("edu/uj/petri/messages").getString("zmiana_nazwy_miejsca");
    }

    void execute() {
        if (oldName == null)
            oldName = place.getName();
        place.setName(newName);
    }

    void undo() {
        place.setName(oldName);
    }

    boolean canBeCombined(Command c) {
        return false;
    }

    private static final long serialVersionUID = 7555613657699659566L;
    
}
